using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EuropeEngulfed.NET
{
    public partial class AxisProductionDialog : Form
    {
        //4.43 COST TO BUILD CHART
        public const int SPECIAL_ACTION_PRICE = 5;
        public const int FLEET_PRICE = 10;
        public const int FLAK_PRICE = 10;
        public const int FIGHTER_PRICE = 3;
        public const int BOMBER_PRICE = 5;

        int germanInitialWERPS;
        int germanFleetMaintenance;
        int germanStrategicWarfareLosses;
        int germanNewUnitsAndReplacements;
        int italianInitialWERPS;
        int italianFleetMaintenance;
        int italianNewUnitsAndReplacements;
        int startingGermanSpecialActions;
        int maxAvailableGermanSpecialActions;
        int startingItalianSpecialActions;
        int maxAvailableItalianSpecialActions;
        bool germanFleetBuildAvailable;
        bool ItalianFleetBuildAvailable;
        bool germanFlakBuildAvailable;
        public struct AxisProductionDialogInfo
        {
            public int italyLoan;
            public int germanSpecialActions;
            public bool germanFleetBuild;
            public bool germanFlakBuild;
            public int UBoats;
            public int fighters;
            public int bombers;
            public int V1;
            public int V2;
            public int italianSpecialActions;
            public bool italianFleetBuild;
        };

        public AxisProductionDialogInfo dialogInfo;

        public AxisProductionDialog(int germanInitialWERPS,int germanFleetMaintenance,int germanStrategicWarfareLosses,int germanNewUnitsAndReplacements,int italianInitialWERPS,int italianFleetMaintenance,int italianNewUnitsAndReplacements,
                                    int startingGermanSpecialActions,int maxAvailableGermanSpecialActions,int startingItalianSpecialActions,int maxAvailableItalianSpecialActions,bool germanFleetBuildAvailable, bool ItalianFleetBuildAvailable,
                                    bool germanFlakBuildAvailable, bool V1BuildAvailable, bool V2BuildAvailable, int startingGermanUBoatPoints)
        {
            this.germanInitialWERPS = germanInitialWERPS;
            this.germanFleetMaintenance = germanFleetMaintenance;
            this.germanStrategicWarfareLosses = germanStrategicWarfareLosses;
            this.germanNewUnitsAndReplacements = germanNewUnitsAndReplacements;
            this.italianInitialWERPS = italianInitialWERPS;
            this.italianFleetMaintenance = italianFleetMaintenance;
            this.italianNewUnitsAndReplacements = italianNewUnitsAndReplacements;
            this.startingGermanSpecialActions = startingGermanSpecialActions;
            this.maxAvailableGermanSpecialActions = maxAvailableGermanSpecialActions;
            this.startingItalianSpecialActions = startingItalianSpecialActions;
            this.maxAvailableItalianSpecialActions = maxAvailableItalianSpecialActions;
            this.germanFleetBuildAvailable = germanFleetBuildAvailable;
            this.ItalianFleetBuildAvailable = ItalianFleetBuildAvailable;
            this.germanFlakBuildAvailable = germanFlakBuildAvailable;
            InitializeComponent();
            this.InitialWERPSAmountLabel.Text = germanInitialWERPS.ToString();
            this.gerrmanFleetMaintenanceAmountLabel.Text = germanFleetMaintenance.ToString();
            this.strategicWarfareAmountLabel.Text = germanStrategicWarfareLosses.ToString();
            this.NewUnitsReplacementsAmountLabel.Text = germanNewUnitsAndReplacements.ToString();
            this.italianInitialWERPSAmountLabel.Text = italianInitialWERPS.ToString();
            this.italianFleetMaintenanceAmountLabel.Text = italianFleetMaintenance.ToString();
            this.italianNewUnitsReplacementsLabel.Text = italianNewUnitsAndReplacements.ToString();
            if (!germanFleetBuildAvailable)
                this.germanFleetBuildCheckBox.Enabled = false;
            if (!ItalianFleetBuildAvailable)
                this.italianFleetBuildCheckbox.Enabled = false;
            if (!germanFlakBuildAvailable)
                this.germanFlakBuildCheckBox.Enabled = false;
            if (!V1BuildAvailable)
                this.V1hScrollBar.Enabled = false;
            if (!V2BuildAvailable)
                this.V2hScrollBar.Enabled = false;
            this.UBoathScrollBar.Maximum = Math.Min(GameState.MAX_UBOATS_IN_A_TURN, GameState.MAX_UBOATS - startingGermanUBoatPoints);
            this.dialogInfo.italyLoan = 0;
            this.dialogInfo.germanSpecialActions = 0;
            this.dialogInfo.germanFleetBuild = false;
            this.dialogInfo.UBoats = 0;
            this.dialogInfo.fighters = 0;
            this.dialogInfo.bombers = 0;
            this.dialogInfo.V1 = 0;
            this.dialogInfo.V2 = 0;
            this.dialogInfo.italianSpecialActions = 0;
            this.dialogInfo.italianFleetBuild = false;
            if ((this.maxAvailableGermanSpecialActions - this.startingGermanSpecialActions) > 0)
                this.specialActionshScrollBar.Maximum = this.maxAvailableGermanSpecialActions - this.startingGermanSpecialActions;
            else
                this.specialActionshScrollBar.Enabled = false;
            if ((this.maxAvailableItalianSpecialActions - this.startingItalianSpecialActions) > 0)
                this.italianSpecialActionshScrollBar.Maximum = this.maxAvailableItalianSpecialActions - this.startingItalianSpecialActions;
            else
                this.italianSpecialActionshScrollBar.Enabled = false;
            this.nextPhaseButton.Visible = false;
            CalculateProductionValues();
        }

        public AxisProductionDialog(int germanInitialWERPS,int germanFleetMaintenance,int germanStrategicWarfareLosses,int germanNewUnitsAndReplacements,int italianInitialWERPS,int italianFleetMaintenance,int italianNewUnitsAndReplacements,
                                    int startingGermanSpecialActions, int maxAvailableGermanSpecialActions, int startingItalianSpecialActions, int maxAvailableItalianSpecialActions, bool germanFleetBuildAvailable, bool ItalianFleetBuildAvailable,
                                    bool germanFlakBuildAvailable, bool V1BuildAvailable, bool V2BuildAvailable, int startingGermanUBoatPoints, AxisProductionDialogInfo productionInfo)
        {
            this.germanInitialWERPS = germanInitialWERPS;
            this.germanFleetMaintenance = germanFleetMaintenance;
            this.germanStrategicWarfareLosses = germanStrategicWarfareLosses;
            this.germanNewUnitsAndReplacements = germanNewUnitsAndReplacements;
            this.italianInitialWERPS = italianInitialWERPS;
            this.italianFleetMaintenance = italianFleetMaintenance;
            this.italianNewUnitsAndReplacements = italianNewUnitsAndReplacements;
            this.startingGermanSpecialActions = startingGermanSpecialActions;
            this.maxAvailableGermanSpecialActions = maxAvailableGermanSpecialActions;
            this.startingItalianSpecialActions = startingItalianSpecialActions;
            this.maxAvailableItalianSpecialActions = maxAvailableItalianSpecialActions;
            this.germanFleetBuildAvailable = germanFleetBuildAvailable;
            this.ItalianFleetBuildAvailable = ItalianFleetBuildAvailable;
            this.germanFlakBuildAvailable = germanFlakBuildAvailable;
            InitializeComponent();
            this.InitialWERPSAmountLabel.Text = germanInitialWERPS.ToString();
            this.gerrmanFleetMaintenanceAmountLabel.Text = germanFleetMaintenance.ToString();
            this.strategicWarfareAmountLabel.Text = germanStrategicWarfareLosses.ToString();
            this.NewUnitsReplacementsAmountLabel.Text = germanNewUnitsAndReplacements.ToString();
            this.italianInitialWERPSAmountLabel.Text = italianInitialWERPS.ToString();
            this.italianFleetMaintenanceAmountLabel.Text = italianFleetMaintenance.ToString();
            this.italianNewUnitsReplacementsLabel.Text = italianNewUnitsAndReplacements.ToString();
            if (!germanFleetBuildAvailable)
                this.germanFleetBuildCheckBox.Enabled = false;
            if (!ItalianFleetBuildAvailable)
                this.italianFleetBuildCheckbox.Enabled = false;
            if (!germanFlakBuildAvailable)
                this.germanFlakBuildCheckBox.Enabled = false;
            if (!V1BuildAvailable)
                this.V1hScrollBar.Enabled = false;
            if (!V2BuildAvailable)
                this.V2hScrollBar.Enabled = false;
            if ((this.maxAvailableGermanSpecialActions - this.startingGermanSpecialActions) > 0)
                this.specialActionshScrollBar.Maximum = this.maxAvailableGermanSpecialActions - this.startingGermanSpecialActions;
            else
                this.specialActionshScrollBar.Enabled = false;
            if ((this.maxAvailableItalianSpecialActions - this.startingItalianSpecialActions) > 0)
                this.italianSpecialActionshScrollBar.Maximum = this.maxAvailableItalianSpecialActions - this.startingItalianSpecialActions;
            else
                this.italianSpecialActionshScrollBar.Enabled = false;
            this.UBoathScrollBar.Maximum = Math.Min(GameState.MAX_UBOATS_IN_A_TURN, GameState.MAX_UBOATS - startingGermanUBoatPoints);
            this.dialogInfo = productionInfo;
            this.specialActionshScrollBar.Value = this.dialogInfo.germanSpecialActions;
            this.UBoathScrollBar.Value = this.dialogInfo.UBoats;
            this.fighterhScrollBar.Value = this.dialogInfo.fighters;
            this.bomberhScrollBar.Value = this.dialogInfo.bombers;
            this.V1hScrollBar.Value = this.dialogInfo.V1;
            this.V2hScrollBar.Value = this.dialogInfo.V2;
            this.italianSpecialActionshScrollBar.Value = this.dialogInfo.italianSpecialActions;
            this.germanFleetBuildCheckBox.Checked = this.dialogInfo.germanFleetBuild;
            this.italianFleetBuildCheckbox.Checked = this.dialogInfo.italianFleetBuild;
            this.germanFlakBuildCheckBox.Checked = this.dialogInfo.germanFlakBuild;
            this.ItalyLoanhScrollBar.Value = this.dialogInfo.italyLoan;
            CalculateProductionValues();
        }

        private void CalculateProductionValues()
        {
            this.loanFromGermanyAmountLabel.Text = this.dialogInfo.italyLoan.ToString();
            this.italyLoanAmountLabel.Text = this.dialogInfo.italyLoan.ToString();
            this.specialActionsAmountLabel.Text = (this.dialogInfo.germanSpecialActions * SPECIAL_ACTION_PRICE).ToString();
            this.germanFleetBuildCheckBox.Checked = this.dialogInfo.germanFleetBuild;
            if (this.dialogInfo.germanFleetBuild)
                this.germanfleetBuildAmountLabel.Text = FLEET_PRICE.ToString();
            else
                this.germanfleetBuildAmountLabel.Text = "0";
            this.germanFlakBuildCheckBox.Checked = this.dialogInfo.germanFlakBuild;
            if (this.dialogInfo.germanFlakBuild)
                this.germanFlakBuildAmountLabel.Text = FLAK_PRICE.ToString();
            else
                this.germanFlakBuildAmountLabel.Text = "0";
            this.UBoatsAmountLabel.Text = this.dialogInfo.UBoats.ToString();
            this.fighterBuildAmountLabel.Text = (this.dialogInfo.fighters * FIGHTER_PRICE).ToString();
            this.bomberBuildAmountLabel.Text = (this.dialogInfo.bombers * BOMBER_PRICE).ToString();
            int V1ProductionCost = this.dialogInfo.V1 / 2;
            this.V1BuildAmountLabel.Text = V1ProductionCost.ToString();
            this.V2BuildAmountLabel.Text = this.dialogInfo.V2.ToString();
            this.italianSpecialActionsAmount.Text = (this.dialogInfo.italianSpecialActions * SPECIAL_ACTION_PRICE).ToString();
            this.italianFleetBuildCheckbox.Checked = this.dialogInfo.italianFleetBuild;
            if(this.dialogInfo.italianFleetBuild)
                this.italianFleetBuildAmountLabel.Text = FLEET_PRICE.ToString();
            int germanWERPSRemaining = (this.germanInitialWERPS - this.germanFleetMaintenance - this.germanStrategicWarfareLosses - this.germanNewUnitsAndReplacements
                                        - this.dialogInfo.italyLoan - (this.dialogInfo.germanSpecialActions * SPECIAL_ACTION_PRICE) - this.dialogInfo.UBoats
                                        - (this.dialogInfo.fighters * FIGHTER_PRICE) - (this.dialogInfo.bombers * BOMBER_PRICE) - V1ProductionCost - this.dialogInfo.V2);
            if (this.dialogInfo.germanFleetBuild)
                germanWERPSRemaining -= FLEET_PRICE;
            if (this.dialogInfo.germanFlakBuild)
                germanWERPSRemaining -= FLAK_PRICE;

            this.germanNumWERPSLeftLabel.Text = germanWERPSRemaining.ToString();
            int italianWERPSLeft = this.italianInitialWERPS - this.italianFleetMaintenance - this.italianNewUnitsAndReplacements + this.dialogInfo.italyLoan
                                    - (this.dialogInfo.italianSpecialActions * SPECIAL_ACTION_PRICE);
            if(this.dialogInfo.italianFleetBuild)
                italianWERPSLeft -= FLEET_PRICE;
            this.italianNumWERPSLeftLabel.Text = italianWERPSLeft.ToString();

            this.numSpecialActions.Text = (this.dialogInfo.germanSpecialActions + startingGermanSpecialActions).ToString();
            this.numUBoatsLabel.Text = this.dialogInfo.UBoats.ToString();
            this.numFighterLabel.Text = this.dialogInfo.fighters.ToString();
            this.numBomberLabel.Text = this.dialogInfo.bombers.ToString();
            this.numV1Label.Text = this.dialogInfo.V1.ToString();
            this.numV2Label.Text = this.dialogInfo.V2.ToString();
            this.numItalianSpecialActions.Text = (this.dialogInfo.italianSpecialActions + this.startingItalianSpecialActions).ToString();
        }
        private void germanProductionGroupBox_Paint(object sender, PaintEventArgs e)
        {
            Bitmap bitmapToDraw;

            PlayingPieceGraphics.PaintControlMarker(e.Graphics, MapInfo.CountryID.Germany, new Point(50, 50), false);
            e.Graphics.DrawLine(Pens.Black, new Point(185, 340), new Point(580, 340));
            bitmapToDraw = EEGraphics.TransparentGermanControlSAs;
            e.Graphics.DrawImage(bitmapToDraw, this.germanSpecialActionsLabel.Location.X - (int)(((float)this.germanSpecialActionsLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanSpecialActionsLabel.Location.Y, (int)(((float)this.germanSpecialActionsLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanSpecialActionsLabel.Height);
            bitmapToDraw = EEGraphics.GermanFlakPoints;
            e.Graphics.DrawImage(bitmapToDraw, this.germanFlakBuildLabel.Location.X - (int)(((float)this.germanFlakBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFlakBuildLabel.Location.Y, (int)(((float)this.germanFlakBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFlakBuildLabel.Height);
            bitmapToDraw = EEGraphics.GermanFleetPoint;
            e.Graphics.DrawImage(bitmapToDraw, this.germanFleetBuildLabel.Location.X - (int)(((float)this.germanFleetBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFleetBuildLabel.Location.Y, (int)(((float)this.germanFleetBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFleetBuildLabel.Height);
            bitmapToDraw = EEGraphics.GermanUBoatPoints;
            e.Graphics.DrawImage(bitmapToDraw, this.germanUBoatLabel.Location.X - (int)(((float)this.germanUBoatLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanUBoatLabel.Location.Y, (int)(((float)this.germanUBoatLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanUBoatLabel.Height);
            bitmapToDraw = EEGraphics.GermanFighterPoints;
            e.Graphics.DrawImage(bitmapToDraw, this.germanFighterBuildLabel.Location.X - (int)(((float)this.germanFighterBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFighterBuildLabel.Location.Y, (int)(((float)this.germanFighterBuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanFighterBuildLabel.Height);
            bitmapToDraw = EEGraphics.GermanBomberPoints;
            e.Graphics.DrawImage(bitmapToDraw, this.germanBomberLabel.Location.X - (int)(((float)this.germanBomberLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanBomberLabel.Location.Y, (int)(((float)this.germanBomberLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanBomberLabel.Height);
            bitmapToDraw = EEGraphics.GermanV1Points;
            e.Graphics.DrawImage(bitmapToDraw, this.germanV1BuildLabel.Location.X - (int)(((float)this.germanV1BuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanV1BuildLabel.Location.Y, (int)(((float)this.germanV1BuildLabel.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanV1BuildLabel.Height);
            bitmapToDraw = EEGraphics.GermanV2Points;
            e.Graphics.DrawImage(bitmapToDraw, this.germanV2Label.Location.X - (int)(((float)this.germanV2Label.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanV2Label.Location.Y, (int)(((float)this.germanV2Label.Height / (float)bitmapToDraw.Height) * (float)bitmapToDraw.Width), this.germanV2Label.Height);
        }

        private void italianProductionGroupBox_Paint(object sender, PaintEventArgs e)
        {
            PlayingPieceGraphics.PaintControlMarker(e.Graphics, MapInfo.CountryID.Italy, new Point(50, 50), false);
            e.Graphics.DrawLine(Pens.Black, new Point(185, 164), new Point(580, 164));
            e.Graphics.DrawImage(EEGraphics.TransparentItalyControlSAs, this.italianSpecialActionsLabel.Location.X - (int)(((float)this.italianSpecialActionsLabel.Height / (float)EEGraphics.ItaFleetPoint.Height) * (float)EEGraphics.ItaFleetPoint.Width), this.italianSpecialActionsLabel.Location.Y, (int)(((float)this.italianSpecialActionsLabel.Height / (float)EEGraphics.ItaFleetPoint.Height) * (float)EEGraphics.ItaFleetPoint.Width), this.italianSpecialActionsLabel.Height);
            e.Graphics.DrawImage(EEGraphics.ItaFleetPoint, this.italianFleetBuildLabel.Location.X - (int)(((float)this.italianFleetBuildLabel.Height / (float)EEGraphics.ItaFleetPoint.Height) * (float)EEGraphics.ItaFleetPoint.Width), this.italianFleetBuildLabel.Location.Y, (int)(((float)this.italianFleetBuildLabel.Height / (float)EEGraphics.ItaFleetPoint.Height) * (float)EEGraphics.ItaFleetPoint.Width), this.italianFleetBuildLabel.Height);
        }

        private void ItalyLoanhScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.italyLoan = this.ItalyLoanhScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.italianNumWERPSLeftLabel.Text) < 0)
            {
                this.ItalyLoanhScrollBar.Value -= Int32.Parse(this.italianNumWERPSLeftLabel.Text);
                this.dialogInfo.italyLoan = this.ItalyLoanhScrollBar.Value;
                CalculateProductionValues();
            }
            else if(Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.ItalyLoanhScrollBar.Value += Int32.Parse(this.germanNumWERPSLeftLabel.Text);
                this.dialogInfo.italyLoan = this.ItalyLoanhScrollBar.Value;
                CalculateProductionValues();
            }

        }

        private void specialActionshScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.germanSpecialActions = this.specialActionshScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.specialActionshScrollBar.Value += (int)Math.Floor(((double)Int32.Parse(this.germanNumWERPSLeftLabel.Text) / (double)SPECIAL_ACTION_PRICE));
                this.dialogInfo.germanSpecialActions = this.specialActionshScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void UBoathScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.UBoats = this.UBoathScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.UBoathScrollBar.Value += Int32.Parse(this.germanNumWERPSLeftLabel.Text);
                this.dialogInfo.UBoats = this.UBoathScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void fighterhScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.fighters = this.fighterhScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.fighterhScrollBar.Value += (int)Math.Floor(((double)Int32.Parse(this.germanNumWERPSLeftLabel.Text) / (double)FIGHTER_PRICE));
                this.dialogInfo.fighters = this.fighterhScrollBar.Value;
                CalculateProductionValues();
            }
            if ((this.dialogInfo.bombers + this.dialogInfo.fighters) > ProductionMove.MAX_NUM_GERMAN_AIRCRAFT_POINTS)
            {
                this.fighterhScrollBar.Value -= (this.dialogInfo.bombers + this.dialogInfo.fighters) - ProductionMove.MAX_NUM_GERMAN_AIRCRAFT_POINTS;
                this.dialogInfo.fighters = this.fighterhScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void bomberhScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.bombers = this.bomberhScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.bomberhScrollBar.Value += (int)Math.Floor(((double)Int32.Parse(this.germanNumWERPSLeftLabel.Text) / BOMBER_PRICE));
                this.dialogInfo.bombers = this.bomberhScrollBar.Value;
                CalculateProductionValues();
            }
            if((this.dialogInfo.bombers + this.dialogInfo.fighters) > ProductionMove.MAX_NUM_GERMAN_AIRCRAFT_POINTS)
            {
                this.bomberhScrollBar.Value -= (this.dialogInfo.bombers + this.dialogInfo.fighters) - ProductionMove.MAX_NUM_GERMAN_AIRCRAFT_POINTS;
                this.dialogInfo.bombers = this.bomberhScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void V1hScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.V1 = this.V1hScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.V1hScrollBar.Value += Int32.Parse(this.germanNumWERPSLeftLabel.Text) * 2;
                this.dialogInfo.V1 = this.V1hScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void V2hScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.V2 = this.V2hScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
            {
                this.V2hScrollBar.Value += Int32.Parse(this.germanNumWERPSLeftLabel.Text);
                this.dialogInfo.V2 = this.V2hScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void italianSpecialActionshScrollBar_ValueChanged(object sender, EventArgs e)
        {
            this.dialogInfo.italianSpecialActions = this.italianSpecialActionshScrollBar.Value;
            CalculateProductionValues();
            if (Int32.Parse(this.italianNumWERPSLeftLabel.Text) < 0)
            {
                this.italianSpecialActionshScrollBar.Value += (int)Math.Floor(((double)Int32.Parse(this.italianNumWERPSLeftLabel.Text) / SPECIAL_ACTION_PRICE));
                this.dialogInfo.italianSpecialActions = this.italianSpecialActionshScrollBar.Value;
                CalculateProductionValues();
            }
        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void nextPhaseButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }

        private void germanFleetBuildCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            this.dialogInfo.germanFleetBuild = this.germanFleetBuildCheckBox.Checked;
            CalculateProductionValues();
            if (this.germanFleetBuildCheckBox.Checked)
            {
                if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
                {
                    this.germanFleetBuildCheckBox.Checked = false;
                }
            }
        }

        private void italianFleetBuildCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            this.dialogInfo.italianFleetBuild = this.italianFleetBuildCheckbox.Checked;
            CalculateProductionValues();
            if(this.italianFleetBuildCheckbox.Checked)
            {
                if (Int32.Parse(this.italianNumWERPSLeftLabel.Text) < 0)
                {
                    this.italianFleetBuildCheckbox.Checked = false;
                }
            }
        }

        private void germanFlakBuildCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            this.dialogInfo.germanFlakBuild = this.germanFlakBuildCheckBox.Checked;
            CalculateProductionValues();
            if (this.germanFlakBuildCheckBox.Checked)
            {
                if (Int32.Parse(this.germanNumWERPSLeftLabel.Text) < 0)
                {
                    this.germanFlakBuildCheckBox.Checked = false;
                }
            }
        }
    }
}